<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>添加、编辑新闻-后台管理-{$site.SITE_INFO.name}</title>
        <php>
            $addCss="";
            $addJs="";
            $currentNav ='资讯管理 > 添加编辑新闻';
        </php>
        <include file="Common:intoHead" />
    </head>
    <body>
        <div class="wrap">
            <include file="Common:head" />
            <div class="mainBody">
                <include file="Common:left" />
                <div id="Right">
                    <div class="Item hr">
                        <div class="current">添加编辑新闻</div>
                    </div>
                    <form>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
                            <tr>
                                <th width="100">文章标题：</th>
                                <td><input id="title" type="text" class="input" size="60" name="info[title]" value="{$info.title}"/> <a href="javascript:void(0)" id="checkNewsTitle">检测是否重复</a></td>
                            </tr>
                            <tr>
                                <th width="100">文章图片：</th>
                                <td id="_picture">
                                    <input id="file_upload" name="file_upload" type="file"  multiple="true">
                                    <input id="picture" type="hidden" class="input" size="60"  name="info[picture]" value="{$info.picture}">
                                    <if condition="$info.picture neq null || $info.picture neq ''"><img id="curr_thumb" src="{$info.picture}" alt="{$info.title}"></if>
                                </td>
                            </tr>
                            <tr>
                                <th width="100">文章标签：</th>
                                <td><input id="tag" type="text" class="input" size="60" name="info[tag]" value="{$info.tag}"/>  多标签间用半角逗号（,）分开，可用于做文章关联阅读条件</td>
                            </tr>
                            <tr>
                                <th width="100">文章发布状态：</th>
                                <td><label><input type="radio" name="info[status]" value="0" <if condition="$info.status eq 0"> checked="checked"</if> /> 文章审核状态</label> &nbsp; <label><input type="radio" name="info[status]" value="1" <if condition="$info.status eq 1"> checked="checked"</if> /> 文章已发布状态</label> </td>
                            </tr>
                            <tr>
                                <th>文章所属分类：</th>
                                <td>
                                    <select name="info[cid]">
                                        <volist name="list" id="vo">
                                            <if condition="$vo[cid] eq $info[cid]">
                                                <option value="{$vo.cid}" selected="selected">{$vo.fullname}</option>
                                                <else/>
                                                <option value="{$vo.cid}">{$vo.fullname}</option>
                                            </if>
                                        </volist>
                                    </select></td>
                            </tr>
                            <tr>
                                <th>文章关键词：</th>
                                <td><input type="text" class="input" size="60" name="info[keywords]" value="{$info.keywords}"/> 多关键词间用半角逗号（,）分开，可用于做文章关联阅读条件</td>
                            </tr>
                            <tr>
                                <th>文章描述：</th>
                                <td><textarea class="input" style="height: 60px; width: 600px;" name="info[description]">{$info.description}</textarea> 用于SEO的description</td>
                            </tr>
                            <tr>
                                <th>文章摘要：</th>
                                <td><textarea class="input" style="height: 60px; width: 600px;" name="info[summary]">{$info.summary}</textarea> 如果不填写则系统自动截取文章前200个字符</td>
                            </tr>
                            <tr>
                                <th>文章内容：</th>
                                <td><textarea id="content" class="input" style="height: 300px; width: 100%;" name="info[content]">{$info.content}</textarea></td>
                            </tr>
                        </table>
                        <input type="hidden" name="info[id]" value="{$info.id}" />
                    </form>
                    <div class="commonBtnArea" >
                        <button class="btn submit">提交</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <include file="Common:foot" />
        <js href="__PUBLIC__/kindeditor/kindeditor.js,__PUBLIC__/kindeditor/lang/zh_CN.js"/>
        <script type="text/javascript">
            $(function(){var  content ;
                KindEditor.ready(function(K) {
                    content = K.create('#content');
                });
                $("#checkNewsTitle").click(function(){
                    $.getJSON("__URL__/checkNewsTitle", { title:$("#title").val(),id:"{$info.id}"}, function(json){
                        $("#checkNewsTitle").css("color",json.status==1?"#0f0":"#f00").html(json.info);
                    });
                });
                $(".submit").click(function(){
                    content.sync();
                    commonAjaxSubmit();
                    return false;
                });
            });
        </script>
        <!--上传图片-->
        <script type="text/javascript">
            <?php $timestamp = time();?>
            $(function() {
                $('#file_upload').uploadify({
                    'onInit': function(){
                        var curr_thumb = $('#curr_thumb').attr('src');
                        curr_thumb = curr_thumb != null && curr_thumb!= '' ? curr_thumb : '';
                        $.cookie('curr_thumb',curr_thumb);
                    },
                    'formData'     : {
                        'timestamp' : '<?php echo $timestamp;?>',
                        'token'     : '<?php echo md5("whoopsfeed_good" . $timestamp);?>'
                    },
                    'simUploadLimit':1,
                    'swf'      : '../Public/Css/uploadify.swf',
                    'uploader' : './system.php?s=/Public/uploadify/',
                    'buttonText' : '<if condition="$info.picture neq null">替换图片<else/>上传图片</if>',
                    'onUploadError' : function(file,errorCode,errorMsg,errorString,swfuploadifyQueue){
                        //alert(errorMsg);//上传文件出错是触发（每个出错文件触发一次）
                        popup.alert(errorMsg);
                    },
                    'onUploadSuccess':function(file,data,response){
                        //alert( 'id: ' + file.id+ ' - 索引: ' + file.index+ ' - 文件名: ' + file.name+ ' - 文件大小: ' + file.size+ ' - 类型: ' + file.type+ ' - 创建日期: ' + file.creationdate+ ' - 修改日期: ' + file.modificationdate+ ' - 文件状态: ' + file.filestatus+ ' - 服务器端消息: ' + data+ ' - 是否上传成功: ' + response);
                        if($.cookie('curr_thumb') && $.cookie('curr_thumb') != null){
                            curr_thumb = $.cookie('curr_thumb');
                            $('#curr_thumb').attr('src','').attr('original','');
                            $('#curr_thumb').attr('src',curr_thumb+'?'+Math.random()).attr('original',curr_thumb);
                        }else{
                            $.cookie('curr_thumb',data);
                            $('#_picture').append('<img id="curr_thumb" src="'+data+'" original="'+data+'" alt="">');
                            $('#picture').val(data);
                        }
                        popup.success('上传图片成功！');
                    },
                    'onSelect': function (event, queueID, fileObj)
                    {
                        $("#file_upload").uploadify('settings','formData',{curr_thumb: $.cookie('curr_thumb')})
                    }
                });
            });

            jQuery.cookie = function(name, value, options) {
                if (typeof value != 'undefined') { // name and value given, set cookie
                    options = options || {};
                    if (value === null) {
                        value = '';
                        options.expires = -1;
                    }
                    var expires = '';
                    if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                        var date;
                        if (typeof options.expires == 'number') {
                            date = new Date();
                            date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                        } else {
                            date = options.expires;
                        }
                        expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
                    }
                    var path = options.path ? '; path=' + options.path : '';
                    var domain = options.domain ? '; domain=' + options.domain : '';
                    var secure = options.secure ? '; secure' : '';
                    document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
                } else { // only name given, get cookie
                    var cookieValue = null;
                    if (document.cookie && document.cookie != '') {
                        var cookies = document.cookie.split(';');
                        for (var i = 0; i < cookies.length; i++) {
                            var cookie = jQuery.trim(cookies[i]);
                            // Does this cookie string begin with the name we want?
                            if (cookie.substring(0, name.length + 1) == (name + '=')) {
                                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                                break;
                            }
                        }
                    }
                    return cookieValue;
                }
            };
        </script>
    </body>
</html>
